<template>
	<view class="comment">
		<view class="uni-list">
			<view class="uni-list-cell uni-list-cell-pd">
				<view class="uni-list-cell-db">护眼模式</view>
				<switch @change="switchChange" :checked="checked" />
			</view>
		</view>
	</view>
</template>

<script>
var that;
export default {
	data() {
		that = this;
		return {
			checked: false
		};
	},
	methods: {
		switchChange: function(e) {
			if (e.target.value) {
				console.log('开启');
				uni.setScreenBrightness({
					value: 0.15,
					success: function() {
						console.log('success');
						that.checked = true
						uni.setStorageSync('setting',true)
					}
				});
			} else {
				console.log('关闭');
				uni.setScreenBrightness({
					value: 0.7,
					success: function() {
						console.log('success');
						that.checked = false
						uni.setStorageSync('setting',false)
					}
				});
			}
		}
	}
};
</script>

<style></style>
